<?php

/**
 * CondoritoEstudiante filter form base class.
 *
 * @package    condorito
 * @subpackage filter
 * @author     Freddy Daniel Garcia
 */
abstract class BaseCondoritoEstudianteFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'codigo'                             => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'primer_nombre'                      => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'primer_apellido'                    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'semestre'                           => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'proyecto_curricular'                => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'tipo_identificacion'                => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'identificacion'                     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'correo_personal'                    => new sfWidgetFormFilterInput(),
      'condorito_estudiante_inscrita_list' => new sfWidgetFormPropelChoice(array('model' => 'CondoritoMateria', 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'codigo'                             => new sfValidatorPass(array('required' => false)),
      'primer_nombre'                      => new sfValidatorPass(array('required' => false)),
      'primer_apellido'                    => new sfValidatorPass(array('required' => false)),
      'semestre'                           => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'proyecto_curricular'                => new sfValidatorPass(array('required' => false)),
      'tipo_identificacion'                => new sfValidatorPass(array('required' => false)),
      'identificacion'                     => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'correo_personal'                    => new sfValidatorPass(array('required' => false)),
      'condorito_estudiante_inscrita_list' => new sfValidatorPropelChoice(array('model' => 'CondoritoMateria', 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('condorito_estudiante_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function addCondoritoEstudianteInscritaListColumnCriteria(Criteria $criteria, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $criteria->addJoin(CondoritoEstudianteInscritaPeer::ID_ESTUDIANTE, CondoritoEstudiantePeer::ID);

    $value = array_pop($values);
    $criterion = $criteria->getNewCriterion(CondoritoEstudianteInscritaPeer::ID_MATERIA, $value);

    foreach ($values as $value)
    {
      $criterion->addOr($criteria->getNewCriterion(CondoritoEstudianteInscritaPeer::ID_MATERIA, $value));
    }

    $criteria->add($criterion);
  }

  public function getModelName()
  {
    return 'CondoritoEstudiante';
  }

  public function getFields()
  {
    return array(
      'id'                                 => 'Number',
      'codigo'                             => 'Text',
      'primer_nombre'                      => 'Text',
      'primer_apellido'                    => 'Text',
      'semestre'                           => 'Number',
      'proyecto_curricular'                => 'Text',
      'tipo_identificacion'                => 'Text',
      'identificacion'                     => 'Number',
      'correo_personal'                    => 'Text',
      'id_usuario'                         => 'ForeignKey',
      'condorito_estudiante_inscrita_list' => 'ManyKey',
    );
  }
}
